package info.sean.util.common.txt;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

public class UnicodeFileUtil {



    public static List<String> readFile(InputStream in) throws IOException {
        BufferedReader br = new BufferedReader(new UnicodeReader(in, Charset.defaultCharset().name()));
        List<String> list = new ArrayList();

        try {
            for(String line = br.readLine(); line != null; line = br.readLine()) {
                list.add(line);
            }
        } finally {
            br.close();
            in.close();
        }

        return list;
    }

    public static List<String> readFile(String filePath) throws IOException {
        FileInputStream in = new FileInputStream(filePath);
        return readFile((InputStream)in);
    }
}
